<?php
namespace app\admin\controller;
use \think\Controller;
use \think\Session;
use \think\Db;
class Formnews extends Common
{
	

  public function editnews(){
    $news = Db::name('news')->where('news_id',input('newsid'))->find();
    $city = Db::name('city')->where('city_status',1)->select();
    $this->assign('news',$news);
    $this->assign('city',$city);
    return $this->fetch();
  }


  public function edit(){
    $info = '';
     if(request()->isPost()){  
        $data=[
          'city_id'=>input('city'),
        ];
        $res=Db::name('news')->where('news_id',input('newsid'))->update($data);
        if ($res!==false){
          $this->success("修改新闻成功",'news/index');
        }
        else {
          $this->error("修改新闻失败");
        }
      }
  }

  public function delete(){
    $res = Db::name('news')->where('news_id',input('newsid'))->delete();
    if($res===false){
        $this->error("处理失败");
    }
    $this->redirect('news/index');
  }
}